<template>
  <bigScreenContainer autoFullScreen>
    <div class="bgPage">
      <div class="HomePageClass" id="HomePageClass">
        <div
          class="page_header"
          :style="{
            background: `url(${componentContent.imageMap['daohang']}) no-repeat`,
            'background-size': '100% 100%',
          }"
        >
          <span>生产看板</span>
        </div>
        <div class="homeContent">
          <div class="middleArea">
            <div class="middle_l">
              <div class="middle_left">
                <div
                  class="title_guangyun"
                  :style="{
                    background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                ></div>
                <div class="title_sb">
                  <div
                    class="title_bg"
                    :style="{
                      background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                      'background-size': '100% 100%',
                    }"
                  >
                    <span>生产订单日报</span>
                  </div>
                </div>
                <div class="chart_sb">
                  <div class="table_">
                    <div class="table-wrapper">
                      <!-- 表头固定 -->
                      <div class="table-header">
                        <el-table
                          :data="tableData1"
                          style="width: 100%"
                          :row-class-name="tableRowClassName"
                          algin="center"
                        >
                          <!-- <el-table-column type="index" label="排名" width="50">
                        </el-table-column> 任务单号	产品名称	产品型号	产线负责人	计划生产数量	完成数量	完成率	直通率	不良率
-->
                          <el-table-column
                            prop="rwdh"
                            label="任务单号"
                            width="200"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cpmc"
                            label="产品名称"
                            width="220"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cpxh"
                            label="产品型号"
                            width="200"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cxfzr"
                            label="产线负责人"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="jhscsl"
                            label="计划生产数量"
                            width="130"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="wcsl"
                            label="完成数量"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="wcl"
                            label="完成率"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="ztl"
                            label="直通率"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="bll"
                            label="不良率"
                            width="100"
                          >
                          </el-table-column>
                        </el-table>
                      </div>

                      <!-- 表格内容可滚动 -->
                      <div
                        class="scroll-wrapper"
                        :style="{
                          transform: `translateY(-${scrollPosition}px)`,
                          transition: isSmooth ? 'transform 1s linear' : 'none',
                        }"
                        @transitionend="onTransitionEnd"
                      >
                        <el-table
                          :data="extendedData"
                          style="width: 100%; height: 100%"
                          ref="table"
                          :show-header="false"
                          :row-class-name="tableRowClassName"
                          algin="center"
                        >
                          <el-table-column
                            prop="rwdh"
                            label="任务单号"
                            width="200"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cpmc"
                            label="产品名称"
                            width="220"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cpxh"
                            label="产品型号"
                            width="200"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="cxfzr"
                            label="产线负责人"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="jhscsl"
                            label="计划生产数量"
                            width="130"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="wcsl"
                            label="完成数量"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="wcl"
                            label="完成率"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="ztl"
                            label="直通率"
                            width="100"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="bll"
                            label="不良率"
                            width="100"
                          >
                          </el-table-column>
                        </el-table>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div class="middle_text">
                <div
                  class="title_guangyun"
                  :style="{
                    background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                ></div>
                <div class="title_sb">
                  <div
                    class="title_bg"
                    :style="{
                      background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                      'background-size': '100% 100%',
                    }"
                  >
                    <span>今日汇总</span>
                  </div>
                </div>
                <div class="chart_sb">
                  <div class="item">
                    <div
                      class="item_left"
                      :style="{
                        background: `url(${componentContent.imageMap['pic1']}) no-repeat`,
                        'background-size': '100% 100%',
                      }"
                    ></div>
                    <div
                      class="item_right"
                      :style="{
                        background: `url(${componentContent.imageMap['item_right']}) no-repeat`,
                        'background-size': 'cover',
                      }"
                    >
                      <span class="item_group_name">今日完成数量</span>
                      <span class="item_group_value">{{ jrwcsl }}</span>
                    </div>
                  </div>
                  <div class="item">
                    <div
                      class="item_left"
                      :style="{
                        background: `url(${componentContent.imageMap['pic2']}) no-repeat`,
                        'background-size': '100% 100%',
                      }"
                    ></div>
                    <div
                      class="item_right"
                      :style="{
                        background: `url(${componentContent.imageMap['item_right']}) no-repeat`,
                        'background-size': '100% 100%',
                      }"
                    >
                      <span class="item_group_name">今日不良数量</span>
                      <span class="item_group_value">{{ jrblsl }}</span>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="middle_r">
              <div class="middle_right">
                <div
                  class="title_guangyun"
                  :style="{
                    background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                ></div>
                <div class="title_sb">
                  <div
                    class="title_bg"
                    :style="{
                      background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                      'background-size': '100% 100%',
                    }"
                  >
                    <span>今日实时直通车</span>
                  </div>
                </div>
                <div class="chart_sb" ref="optionBar1"></div>
              </div>
              <div class="middle_right">
                <div
                  class="title_guangyun"
                  :style="{
                    background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                ></div>
                <div class="title_sb">
                  <div
                    class="title_bg"
                    :style="{
                      background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                      'background-size': '100% 100%',
                    }"
                  >
                    <span>今日时段产能统计</span>
                  </div>
                </div>
                <div class="chart_sb" ref="optionBar2"></div>
              </div>
            </div>
          </div>
          <div class="bottomArea">
            <div class="bottom_left">
              <div
                class="title_guangyun"
                :style="{
                  background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                  'background-size': '100% 100%',
                }"
              ></div>
              <div class="title_sb">
                <div
                  class="title_bg"
                  :style="{
                    background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                >
                  <span>一周不良项统计</span>
                </div>
              </div>
              <div class="chart_sb" ref="optionBar3"></div>
            </div>
            <div class="bottom_left">
              <div
                class="title_guangyun"
                :style="{
                  background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                  'background-size': '100% 100%',
                }"
              ></div>
              <div class="title_sb">
                <div
                  class="title_bg"
                  :style="{
                    background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                >
                  <span>一周不良项占比</span>
                </div>
              </div>
              <div class="chart_sb" ref="optionBar4"></div>
            </div>
            <div class="bottom_left">
              <div
                class="title_guangyun"
                :style="{
                  background: `url(${componentContent.imageMap['guangyun']}) no-repeat`,
                  'background-size': '100% 100%',
                }"
              ></div>
              <div class="title_sb">
                <div
                  class="title_bg"
                  :style="{
                    background: `url(${componentContent.imageMap['titlebg']}) no-repeat`,
                    'background-size': '100% 100%',
                  }"
                >
                  <span>一周产能趋势统计</span>
                </div>
              </div>
              <div class="chart_sb" ref="optionBar5"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </bigScreenContainer>
</template>
<script>
// import * as echarts from "echarts";

export default {
  name: "sjkbView", // 研发
  data() {
    return {
      componentContent,
      nowYear: "",
      nowMonth: "",
      monthData: [
        "1月",
        "2月",
        "3月",
        "4月",
        "5月",
        "6月",
        "7月",
        "8月",
        "9月",
        "10月",
        "11月",
        "12月",
      ],
      data1: [0, 0, 0, 0, 0, 0, 0, 0],
      data2: [0, 0, 0, 0, 0, 0, 0, 0],
      data3: [0, 0, 0, 0, 0, 0, 0],
      data4: [0, 0, 0, 0, 0, 0, 0],
      data5: [0, 0, 0, 0, 0, 0, 0],
      jrwcsl: 0,
      jrblsl: 0,
      extendedData: [], // 扩展后的数据（首尾相连）
      scrollPosition: 0, // 当前滚动位置
      rowHeight: 50, // 单行高度（需根据实际表格调整）
      isSmooth: true, // 是否启用平滑滚动
      timer: null, // 定时器
      tableData1: [],
      tableData: [],
    };
  },
  computed: {
    optionBar1() {
      return {
        color: ["#5470C6"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
          borderWidth: 0, // 边框宽度（可选）
          backgroundColor: "rgba(0, 91, 174, 0.8)", // 背景颜色（支持透明度）
          textStyle: {
            color: "#ffffff", // 文字颜色
          },
        },
        grid: {
          left: "7%",
          right: "3%",
          top: "20%",
          bottom: "10%",
        },
        toolbox: {},
        legend: {
          data: ["HVAC一次合格率"],
          top: 10,
          right: 20,
          itemWidth: 14, // 图标宽度
          itemHeight: 14, // 图标高度
          textStyle: {
            color: "#ffffff", // 字体颜色
            fontSize: 14, // 字号
            fontFamily: "Arial", // 字体
            padding: [0, 0, 0, 0], // 文本左侧间距
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              alignWithLabel: true,
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.2)",
              },
            },
            // prettier-ignore
            data: ["8:00","9:00","10:00","11:00","14:00","15:00","16:00","17:00"],
            axisLabel: {
              color: "#ffffff",
              formatter: "{value}",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位 : 件", // 通用名称（或根据需求自定义）
            position: "left", // 统一放在左侧
            axisLine: {
              show: false,
            },
            nameTextStyle: {
              color: "rgba(255,255,255,0.8)",
              padding: [0, 25, 0, 0], // 调整旋转后的位置
            },
            axisLabel: {
              color: "#ffffff",
              fontWeight: 700,
              formatter: "{value}",
            },
            splitLine: {
              lineStyle: {
                type: "dashed", // 设置横线为虚线
                color: "rgba(255,255,255,0.2)", // 可选：设置虚线颜色（带透明度）
              },
            },
          },
        ],
        series: [
          {
            name: "今日实时直通车",
            type: "line",
            smooth: true,
            barWidth: 24,
            data: this.data1,
            itemStyle: {
              color: {
                type: "linear", // 线性渐变
                x: 0, // 右方向
                y: 0, // 下方向
                x2: 0, // 左方向（0表示垂直渐变）
                y2: 1, // 底部终点
                colorStops: [
                  {
                    offset: 1,
                    color: "#2378f7", // 0%处的颜色
                  },
                  {
                    offset: 0,
                    color: "#83bff6", // 100%处的颜色
                  },
                ],
              },
            },
          },
        ],
      };
    },
    optionBar2() {
      return {
        color: ["#5470C6"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
          borderWidth: 0, // 边框宽度（可选）
          backgroundColor: "rgba(0, 91, 174, 0.8)", // 背景颜色（支持透明度）
          textStyle: {
            color: "#ffffff", // 文字颜色
          },
        },
        grid: {
          left: "7%",
          right: "3%",
          top: "20%",
          bottom: "10%",
        },
        toolbox: {},
        legend: {
          data: ["HVAC一次合格率"],
          top: 10,
          right: 20,
          itemWidth: 14, // 图标宽度
          itemHeight: 14, // 图标高度
          textStyle: {
            color: "#ffffff", // 字体颜色
            fontSize: 14, // 字号
            fontFamily: "Arial", // 字体
            padding: [0, 0, 0, 0], // 文本左侧间距
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              alignWithLabel: true,
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.2)",
              },
            },
            // prettier-ignore
            data: ["8:00","9:00","10:00","11:00","14:00","15:00","16:00","17:00"],
            axisLabel: {
              color: "#ffffff",
              formatter: "{value}",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位 : 件", // 通用名称（或根据需求自定义）
            position: "left", // 统一放在左侧
            axisLine: {
              show: false,
            },
            nameTextStyle: {
              color: "rgba(255,255,255,0.8)",
              padding: [0, 25, 0, 0], // 调整旋转后的位置
            },
            axisLabel: {
              color: "#ffffff",
              fontWeight: 700,
              formatter: "{value}",
            },
            splitLine: {
              lineStyle: {
                type: "dashed", // 设置横线为虚线
                color: "rgba(255,255,255,0.2)", // 可选：设置虚线颜色（带透明度）
              },
            },
          },
        ],
        series: [
          {
            name: "今日时段产能统计",
            type: "line",
            barWidth: 24,
            data: this.data1,
            itemStyle: {
              color: {
                type: "linear", // 线性渐变
                x: 0, // 右方向
                y: 0, // 下方向
                x2: 0, // 左方向（0表示垂直渐变）
                y2: 1, // 底部终点
                colorStops: [
                  {
                    offset: 1,
                    color: "#2378f7", // 0%处的颜色
                  },
                  {
                    offset: 0,
                    color: "#83bff6", // 100%处的颜色
                  },
                ],
              },
            },
          },
        ],
      };
    },
    optionBar3() {
      return {
        color: ["#5470C6"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
          borderWidth: 0, // 边框宽度（可选）
          backgroundColor: "rgba(0, 91, 174, 0.8)", // 背景颜色（支持透明度）
          textStyle: {
            color: "#ffffff", // 文字颜色
          },
        },
        grid: {
          left: "7%",
          right: "3%",
          top: "20%",
          bottom: "10%",
        },
        toolbox: {},
        legend: {
          data: ["HVAC一次合格率"],
          top: 10,
          right: 20,
          itemWidth: 14, // 图标宽度
          itemHeight: 14, // 图标高度
          textStyle: {
            color: "#ffffff", // 字体颜色
            fontSize: 14, // 字号
            fontFamily: "Arial", // 字体
            padding: [0, 0, 0, 0], // 文本左侧间距
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              alignWithLabel: true,
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.2)",
              },
            },
            // prettier-ignore
            data: ["周一","周二","周三","周四","周五","周六","周日"],
            axisLabel: {
              color: "#ffffff",
              formatter: "{value}",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位 : 件", // 通用名称（或根据需求自定义）
            position: "left", // 统一放在左侧
            axisLine: {
              show: false,
            },
            nameTextStyle: {
              color: "rgba(255,255,255,0.8)",
              padding: [0, 25, 0, 0], // 调整旋转后的位置
            },
            axisLabel: {
              color: "#ffffff",
              fontWeight: 700,
              formatter: "{value}",
            },
            splitLine: {
              lineStyle: {
                type: "dashed", // 设置横线为虚线
                color: "rgba(255,255,255,0.2)", // 可选：设置虚线颜色（带透明度）
              },
            },
          },
        ],
        series: [
          {
            name: "一周不良项统计",
            type: "line",
            smooth: true,
            barWidth: 24,
            data: this.data3,
            itemStyle: {
              color: {
                type: "linear", // 线性渐变
                x: 0, // 右方向
                y: 0, // 下方向
                x2: 0, // 左方向（0表示垂直渐变）
                y2: 1, // 底部终点
                colorStops: [
                  {
                    offset: 1,
                    color: "#2378f7", // 0%处的颜色
                  },
                  {
                    offset: 0,
                    color: "#83bff6", // 100%处的颜色
                  },
                ],
              },
            },
          },
        ],
      };
    },
    optionBar4() {
      return {
        color: ["#5470C6"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
          borderWidth: 0, // 边框宽度（可选）
          backgroundColor: "rgba(0, 91, 174, 0.8)", // 背景颜色（支持透明度）
          textStyle: {
            color: "#ffffff", // 文字颜色
          },
        },
        grid: {
          left: "7%",
          right: "3%",
          top: "20%",
          bottom: "10%",
        },
        toolbox: {},
        legend: {
          data: ["HVAC一次合格率"],
          top: 10,
          right: 20,
          itemWidth: 14, // 图标宽度
          itemHeight: 14, // 图标高度
          textStyle: {
            color: "#ffffff", // 字体颜色
            fontSize: 14, // 字号
            fontFamily: "Arial", // 字体
            padding: [0, 0, 0, 0], // 文本左侧间距
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              alignWithLabel: true,
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.2)",
              },
            },
            // prettier-ignore
            data: ["周一","周二","周三","周四","周五","周六","周日"],
            axisLabel: {
              color: "#ffffff",
              formatter: "{value}",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位 : %", // 通用名称（或根据需求自定义）
            position: "left", // 统一放在左侧
            axisLine: {
              show: false,
            },
            nameTextStyle: {
              color: "rgba(255,255,255,0.8)",
              padding: [0, 25, 0, 0], // 调整旋转后的位置
            },
            axisLabel: {
              color: "#ffffff",
              fontWeight: 700,
              formatter: "{value}",
            },
            splitLine: {
              lineStyle: {
                type: "dashed", // 设置横线为虚线
                color: "rgba(255,255,255,0.2)", // 可选：设置虚线颜色（带透明度）
              },
            },
          },
        ],
        series: [
          {
            name: "一周不良项占比",
            type: "bar",
            barWidth: 24,
            data: this.data4,
            itemStyle: {
              color: {
                type: "linear", // 线性渐变
                x: 0, // 右方向
                y: 0, // 下方向
                x2: 0, // 左方向（0表示垂直渐变）
                y2: 1, // 底部终点
                colorStops: [
                  {
                    offset: 1,
                    color: "#2378f7", // 0%处的颜色
                  },
                  {
                    offset: 0,
                    color: "#83bff6", // 100%处的颜色
                  },
                ],
              },
            },
          },
        ],
      };
    },
    optionBar5() {
      return {
        color: ["#5470C6"],
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
          },
          borderWidth: 0, // 边框宽度（可选）
          backgroundColor: "rgba(0, 91, 174, 0.8)", // 背景颜色（支持透明度）
          textStyle: {
            color: "#ffffff", // 文字颜色
          },
        },
        grid: {
          left: "7%",
          right: "3%",
          top: "20%",
          bottom: "10%",
        },
        toolbox: {},
        legend: {
          data: ["HVAC一次合格率"],
          top: 10,
          right: 20,
          itemWidth: 14, // 图标宽度
          itemHeight: 14, // 图标高度
          textStyle: {
            color: "#ffffff", // 字体颜色
            fontSize: 14, // 字号
            fontFamily: "Arial", // 字体
            padding: [0, 0, 0, 0], // 文本左侧间距
          },
        },
        xAxis: [
          {
            type: "category",
            axisTick: {
              alignWithLabel: true,
            },
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.2)",
              },
            },
            // prettier-ignore
            data: ["周一","周二","周三","周四","周五","周六","周日"],
            axisLabel: {
              color: "#ffffff",
              formatter: "{value}",
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位 : 件", // 通用名称（或根据需求自定义）
            position: "left", // 统一放在左侧
            axisLine: {
              show: false,
            },
            nameTextStyle: {
              color: "rgba(255,255,255,0.8)",
              padding: [0, 25, 0, 0], // 调整旋转后的位置
            },
            axisLabel: {
              color: "#ffffff",
              fontWeight: 700,
              formatter: "{value}",
            },
            splitLine: {
              lineStyle: {
                type: "dashed", // 设置横线为虚线
                color: "rgba(255,255,255,0.2)", // 可选：设置虚线颜色（带透明度）
              },
            },
          },
        ],
        series: [
          {
            name: "一周产能趋势统计",
            type: "line",
            smooth: true,
            barWidth: 24,
            data: this.data5,
            itemStyle: {
              color: {
                type: "linear", // 线性渐变
                x: 0, // 右方向
                y: 0, // 下方向
                x2: 0, // 左方向（0表示垂直渐变）
                y2: 1, // 底部终点
                colorStops: [
                  {
                    offset: 1,
                    color: "#2378f7", // 0%处的颜色
                  },
                  {
                    offset: 0,
                    color: "#83bff6", // 100%处的颜色
                  },
                ],
              },
            },
          },
        ],
      };
    },
  },
  async created() {
    this.nowYear = new Date().getFullYear();
    this.nowDay = new Date().getDay();
    if (this.nowDay == 0) {
      this.nowDay = 7;
    }
    this.nowMonth = (new Date().getMonth() + 1).toString().padStart(2, "0");
    this.nowDate = new Date().getDate();
    console.log(this.nowYear, this.nowDay, this.nowMonth, this.nowDate);
  },
  async mounted() {
    await Promise.all([this.getData1(), this.getData2(), this.getData3()]).then(
      ([result1, result2, result3]) => {
        console.log("所有请求完成：");
        console.log("数据:", result1, result2, result3);

        for (let index = 1; index <= this.nowDay; index++) {
          let result2FilterData = result2.filter((item) => {
            let filterStr =
              this.nowYear +
              "-" +
              this.nowMonth +
              "-" +
              (this.nowDate - this.nowDay + index).toString().padStart(2, "0");
            console.log(filterStr);
            return item.date.includes(filterStr);
          });
          console.log(result2FilterData);
          if (result2FilterData.length > 0) {
            this.data3[index - 1] = result2FilterData[0].yzblxtj;
            this.data4[index - 1] = result2FilterData[0].yzblxzb;
            this.data5[index - 1] = result2FilterData[0].yzcnqstj;
          } else {
            this.data3[index - 1] = 0;
            this.data4[index - 1] = 0;
            this.data5[index - 1] = 0;
          }
        }

        let result3D1 = result3.filter((item) => {
          return item.time == "8";
        });
        console.log(result3D1);
        if (result3D1.length > 0) {
          this.data1[0] = result3D1[0].jrssztc;
          this.data2[0] = result3D1[0].jrsdcntjt;
        } else {
          this.data1[0] = 0;
          this.data2[0] = 0;
        }

        let result3D2 = result3.filter((item) => {
          return item.time == "9";
        });
        if (result3D2.length > 0) {
          this.data1[1] = result3D2[0].jrssztc;
          this.data2[1] = result3D2[0].jrsdcntjt;
        } else {
          this.data1[1] = 0;
          this.data2[1] = 0;
        }

        let result3D3 = result3.filter((item) => {
          return item.time == "10";
        });
        if (result3D3.length > 0) {
          this.data1[2] = result3D3[0].jrssztc;
          this.data2[2] = result3D3[0].jrsdcntjt;
        } else {
          this.data1[2] = 0;
          this.data2[2] = 0;
        }

        let result3D4 = result3.filter((item) => {
          return item.time == "11";
        });
        if (result3D4.length > 0) {
          this.data1[3] = result3D4[0].jrssztc;
          this.data2[3] = result3D4[0].jrsdcntjt;
        } else {
          this.data1[3] = 0;
          this.data2[3] = 0;
        }

        let result3D5 = result3.filter((item) => {
          return item.time == "14";
        });
        if (result3D5.length > 0) {
          this.data1[4] = result3D5[0].jrssztc;
          this.data2[4] = result3D5[0].jrsdcntjt;
        } else {
          this.data1[4] = 0;
          this.data2[4] = 0;
        }

        let result3D16 = result3.filter((item) => {
          return item.time == "15";
        });
        if (result3D16.length > 0) {
          this.data1[5] = result3D16[0].jrssztc;
          this.data2[5] = result3D16[0].jrsdcntjt;
        } else {
          this.data1[5] = 0;
          this.data2[5] = 0;
        }

        let result3D17 = result3.filter((item) => {
          return item.time == "16";
        });
        if (result3D17.length > 0) {
          this.data1[6] = result3D17[0].jrssztc;
          this.data2[6] = result3D17[0].jrsdcntjt;
        } else {
          this.data1[6] = 0;
          this.data2[6] = 0;
        }

        let result3D18 = result3.filter((item) => {
          return item.time == "17";
        });
        if (result3D18.length > 0) {
          this.data1[7] = result3D18[0].jrssztc;
          this.data2[7] = result3D18[0].jrsdcntjt;
        } else {
          this.data1[7] = 0;
          this.data2[7] = 0;
        }

        let result2TodayData = result2.filter((item) => {
          let filterStr =
            this.nowYear +
            "-" +
            this.nowMonth +
            "-" +
            this.nowDate.toString().padStart(2, "0");
          return item.date.includes(filterStr);
        });
        if (result2TodayData.length > 0) {
          this.jrblsl = result2TodayData[0].jrblsl;
          this.jrwcsl = result2TodayData[0].jrwcsl;
        }

        this.tableData = result1;
        this.initializeData(); // 初始化数据
        this.startScroll(); // 开始滚动

        this.$nextTick(() => {
          // 动态 DOM 更新后重新获取高度
          const heights = this.getRowHeights();
          this.rowHeight = heights[0];
          console.log("更新后的行高：", heights);
          echarts.init(this.$refs.optionBar1).setOption(this.optionBar1);
          echarts.init(this.$refs.optionBar2).setOption(this.optionBar2);
          echarts.init(this.$refs.optionBar3).setOption(this.optionBar3);
          echarts.init(this.$refs.optionBar4).setOption(this.optionBar4);
          echarts.init(this.$refs.optionBar5).setOption(this.optionBar5);
        });
      }
    );
  },
  beforeDestroy() {
    this.stopScroll(); // 清除定时器
  },
  methods: {
    getRowHeights() {
      // 获取表格的 DOM 元素
      const tableElement = this.$refs.table.$el;
      console.log(tableElement);
      // 获取所有行
      const rows = tableElement.querySelectorAll(".el-table__row");
      // 遍历每一行并获取高度
      const heights = Array.from(rows).map((row) => row.offsetHeight);
      console.log("每行高度：", heights);
      return heights;
    },
    // 初始化扩展数据
    initializeData() {
      // 扩展数据：将原始数据复制一份追加到末尾
      this.extendedData = [...this.tableData, ...this.tableData];
    },
    // 开始滚动
    startScroll() {
      this.timer = setInterval(() => {
        this.scrollPosition += this.rowHeight; // 向下滚动一行
        this.isSmooth = true; // 平滑过渡
        // 如果滚动到最后一行（原始数据长度），等待过渡完成后跳回顶部
        if (this.scrollPosition >= this.rowHeight * this.tableData.length) {
          setTimeout(() => {
            this.isSmooth = false; // 关闭过渡
            this.scrollPosition = 0; // 瞬间跳回顶部
          }, 1900);
        }
      }, 2000); // 每2秒滚动一次
    },
    // 停止滚动
    stopScroll() {
      clearInterval(this.timer);
    },
    // 监听过渡结束事件（备用）
    onTransitionEnd() {
      if (this.scrollPosition >= this.rowHeight * this.tableData.length) {
        this.isSmooth = false;
        this.scrollPosition = 0;
      }
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 4 == 1) {
        return "warning-row";
      } else if (rowIndex % 4 == 3) {
        return "success-row";
      }
      return "odd-row";
    },
    getData1() {
      return new Promise((resolve, reject) => {
        this.WitGlobal.requestCode("main.main.selectjhzxqk", {}).then((res) => {
          if (res.code == 200) {
            resolve(res.data);
          } else {
            reject("err");
          }
        });
      });
    },
    getData2() {
      return new Promise((resolve, reject) => {
        this.WitGlobal.requestCode("main.main.selectsckbr", {}).then((res) => {
          if (res.code == 200) {
            resolve(res.data);
          } else {
            reject("err");
          }
        });
      });
    },
    getData3() {
      return new Promise((resolve, reject) => {
        this.WitGlobal.requestCode("main.main.selectsckbs", {}).then((res) => {
          if (res.code == 200) {
            resolve(res.data);
          } else {
            reject("err");
          }
        });
      });
    },
    setMonthData(arr = [{}], data) {
      if (this.nowMonth >= 1) data[0] = Number(arr[0].january);
      else data[0] = 0;
      if (this.nowMonth >= 2) data[1] = Number(arr[0].february);
      else data[1] = 0;
      if (this.nowMonth >= 3) data[2] = Number(arr[0].march);
      else data[2] = 0;
      if (this.nowMonth >= 4) data[3] = Number(arr[0].april);
      else data[3] = 0;
      if (this.nowMonth >= 5) data[4] = Number(arr[0].may);
      else data[4] = 0;
      if (this.nowMonth >= 6) data[5] = Number(arr[0].june);
      else data[5] = 0;
      if (this.nowMonth >= 7) data[6] = Number(arr[0].july);
      else data[6] = 0;
      if (this.nowMonth >= 8) data[7] = Number(arr[0].august);
      else data[7] = 0;
      if (this.nowMonth >= 9) data[8] = Number(arr[0].september);
      else data[8] = 0;
      if (this.nowMonth >= 10) data[10] = Number(arr[0].october);
      else data[10] = 0;
      if (this.nowMonth >= 11) data[11] = Number(arr[0].november);
      else data[11] = 0;
      if (this.nowMonth >= 12) data[12] = Number(arr[0].december);
      else data[12] = 0;
    },
  },
};
</script>
<style lang="scss" scoped>
.el-table td > .cell {
  padding-left: 10px;
}

.el-table {
  height: 284px;
}

.el-table .warning-row {
  background: rgba(52, 57, 70, 0.2);
}

.el-table .success-row {
  background: rgba(52, 57, 70, 0.2);
}

.el-table .odd-row {
  background: rgba(29, 35, 49, 0.2);
}

.el-table .el-table__cell {
  font-size: 16px !important;
  text-align: center;
}

.table_ {
  width: 100%;
  height: 284px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
}

.el-table th {
  background-color: rgba(29, 35, 49, 0.2);
  color: #409eff;
}

.el-table {
  background: rgba(29, 35, 49, 0.2);
  color: #dddddd;
}

.table-wrapper {
  position: relative;
  /* 设置表格总高度，包含表头 */
}

.table-header .el-table {
  margin-top: -2px;
  height: 44px;
}

.table-header {
  /* 表头固定在顶部 */
  position: relative;
  top: 0px;
  height: 44px;
  z-index: 1;

  /* 确保表头在上层 */
  .el-table tr {
    background-color: #034f79;
  }
}

.scroll-wrapper {
  /* 表格内容容器，滚动的部分 */
  // height: 100%;
  /* 隐藏溢出的内容 */
  // position: relative;
  // display: block;
  overflow: hidden;
}

.scroll-wrapper .el-table__body {
  /* 内容部分需要启用平滑滚动效果 */
  will-change: transform;
}

/* 自定义渐变色进度条 */
.custom-gradient-progress .el-progress-bar__inner {
  background: linear-gradient(270deg, #00efff 0%, #00527d 100%) !important;
  transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1);
  border-radius: 4px;
}

.el-progress-bar__outer {
  background-color: rgb(27, 63, 99);
  height: 3px !important;
  border-radius: 4px;
}

.table_ {
  width: 100%;
  height: 284px;
  background: rgba(255, 255, 255, 0);
  position: relative;
  overflow: hidden;
}

// rgb(14, 58, 104);
.table-wrapper {
  position: relative;
  /* 设置表格总高度，包含表头 */
}

.table-header {
  /* 表头固定在顶部 */
  position: relative;
  top: 0px;
  height: 40px;
  z-index: 1;
  /* 确保表头在上层 */
}

.scroll-wrapper {
  /* 表格内容容器，滚动的部分 */
  // height: 100%;
  /* 隐藏溢出的内容 */
  // position: relative;
  // display: block;
  overflow: hidden;
}

.scroll-wrapper .el-table__body {
  /* 内容部分需要启用平滑滚动效果 */
  will-change: transform;
}

.no-hover-table .el-table__body tr:hover > td {
  background-color: transparent !important;
}

.no-hover-table .el-table__row {
  background-color: rgba(10, 43, 82, 0.99);
  /* 略透明 */
}

#no-hover-table {
  background-color: transparent !important;

  td {
    background: rgb(10, 43, 82) !important;
    color: #ffffff;
    height: 40px !important;
    border: 0px solid rgba(25, 198, 255, 0) !important;
    border-top: 1px solid rgb(28, 100, 146) !important;
    border-bottom: 1px solid rgb(28, 100, 146) !important;
  }

  td:first-child {
    border-left: 1px solid rgb(28, 100, 146) !important;
    // border-radius: 6px 0px 0px 6px;
  }

  td:nth-last-child(1) {
    border-right: 1px solid rgb(28, 100, 146) !important;
    // border-radius: 0px 6px 6px 0px;
  }
}

.no-hover-table.el-table {
  border: 0px solid #ebeef5;
}

.no-hover-table .el-table__body,
.no-hover-table .el-table__header {
  border-collapse: separate !important;
  border-spacing: 0 4px !important;
  /* 行间距设置在这里！ */
  background: transparent;
}

.custom-header-table.el-table {
  background: rgb(8, 47, 84) !important;
  border: 0px solid #ebeef5;
}

.el-table td > .cell {
  padding-left: 10px;
}

.custom-header-table {
  /* 表头整体样式 */
  .el-table__header-wrapper {
    th {
      background: rgb(8, 47, 84) !important;
      // background: rgb(41, 76, 146) !important;
      // border: 1px solid rgba(25, 198, 255, 0) !important;
      border-bottom: 1px solid rgb(28, 100, 146) !important;
      border-top: 1px solid rgb(28, 100, 146) !important;
      border-left: 1px solid rgb(8, 47, 84) !important;
      border-right: 1px solid rgb(8, 47, 84) !important;
      box-sizing: border-box;

      /* 文字样式 */
      .cell {
        color: #ffffff; // 文字颜色
      }
    }

    th:first-child {
      border-left: 1px solid rgb(28, 100, 146) !important;
    }

    th:nth-last-child(2) {
      border-right: 1px solid rgb(28, 100, 146) !important;
    }

    // /* 表头悬停效果 */
    // tr:hover > th {
    //   background-color: transparent !important;
    // }
  }

  /* 表格边框合并模式 */
  &.el-table--border {
    border-collapse: collapse;

    th:first-child {
      border-left: 1px solid rgba(25, 198, 255, 0.3);
    }

    th:last-child {
      border-right: 1px solid rgba(25, 198, 255, 0.3);
    }
  }

  /* 调整表头高度 */
  .el-table__header {
    tr {
      height: 40px; // 自定义表头高度
    }
  }
}

.table-header .el-table {
  height: 40px;
}

.page_header {
  height: 80px;
  line-height: 70px;
  background: url(./daohang.png) no-repeat;
  background-size: cover;
  font-weight: 600;
  font-size: 24px;
  text-align: center;

  span {
    // font-weight: 600;
    // font-size: 40px;
    // color: #ffffff;
    // text-shadow: 0px 10px 10px rgba(0, 0, 0, 0.2);
    // background: linear-gradient(0deg, #99bbff 0%, #ffffff 100%);
    // background-clip: text;
    // -webkit-background-clip: text;
    // -webkit-text-fill-color: transparent;
    // text-align: center;
    // padding-top: 36px;
    font-family: "PangMenZhengDao";
    font-size: 38px;
    font-weight: 700;
    line-height: 44.46px;
    letter-spacing: 2px;

    font-variation-settings: "opsz" auto;
    background: linear-gradient(180deg, #ffffff 30%, #90c4ff 81%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    // text-fill-color: transparent;
    text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.05);
  }
}

.bgPage {
  width: 1920px;
  height: 1080px;
  background: #111726;
}

.text_color {
  color: #ffffff;
}

.text_num_red {
  font-variation-settings: "opsz" auto;
  background: linear-gradient(180deg, #ffffff 48%, #ff5050 83%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text_num {
  font-variation-settings: "opsz" auto;
  background: linear-gradient(180deg, #fdfeff 49%, #0ac3ff 83%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  // text-fill-color: transparent;
  text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}

.big_num {
  font-weight: 700;
  font-size: 40px;
}

.little_num {
  font-size: 28px;
  font-weight: 700;
}

.HomePageClass {
  width: 1920px;
  height: 1080px;
  // background: url(./bg.png) no-repeat;
  background: linear-gradient(90deg, #061726 13%, #003a6d 49%, #061726 86%);
  background-size: cover;
  display: flex;
  flex-direction: column;

  .homeContent {
    display: flex;
    flex-direction: column;
    align-items: center;

    .bottomArea {
      margin-bottom: 20px;
      width: 1920px;
      display: flex;
      justify-content: space-evenly;

      .bottom_left,
      .bottom_right {
        width: 614px;
        height: 308px;
        position: relative;

        .title_guangyun {
          width: 124px;
          height: 70px;
          position: absolute;
          background: url(./guangyun.png) no-repeat;
          background-size: cover;
        }

        .title_sb {
          width: 614px;
          height: 40px;
          background: linear-gradient(
            90deg,
            rgba(57, 125, 175, 0) -1%,
            rgba(57, 125, 175, 0.15) 48%,
            rgba(57, 125, 175, 0) 100%
          );
          font-family: Arial;
          font-size: 18px;
          font-weight: normal;
          line-height: 40px;
          letter-spacing: 0px;
          color: #ffffff;
          text-shadow: 0px 2px 24px #00c0ff;

          .title_bg {
            width: 548px;
            height: 40px;
            background: url(./titlebg.png) no-repeat;
            background-size: cover;

            span {
              padding-left: 40px;
            }
          }
        }

        .chart_sb {
          margin-top: 6px;
          width: 614px;
          height: 276px;
          background: linear-gradient(
            180deg,
            rgba(39, 126, 255, 0.015) -3%,
            rgba(39, 177, 255, 0.12) 100%
          );
          box-shadow: inset 0px 10px 50px 0px rgba(55, 169, 238, 0.05);
          display: flex;
          justify-content: start;
        }
      }
    }

    .middleArea {
      margin-bottom: 20px;
      width: 1920px;
      display: flex;
      justify-content: space-evenly;

      .middle_l {
        width: 1250px;
        height: 660px;
        display: flex;
        flex-direction: column;
        justify-content: start;

        .middle_left {
          width: 1250px;
          height: 460px;
          margin-bottom: 20px;

          .title_guangyun {
            width: 124px;
            height: 70px;
            position: absolute;
            background: url(./guangyun.png) no-repeat;
            background-size: cover;
          }

          .title_sb {
            width: 1250px;
            height: 40px;
            background: linear-gradient(
              90deg,
              rgba(57, 125, 175, 0) -1%,
              rgba(57, 125, 175, 0.15) 48%,
              rgba(57, 125, 175, 0) 100%
            );
            font-family: Arial;
            font-size: 18px;
            font-weight: normal;
            line-height: 40px;
            letter-spacing: 0px;
            color: #ffffff;
            text-shadow: 0px 2px 24px #00c0ff;

            .title_bg {
              width: 548px;
              height: 40px;
              background: url(./titlebg.png) no-repeat;
              background-size: cover;

              span {
                padding-left: 40px;
              }
            }
          }

          .chart_sb {
            margin-top: 6px;
            width: 1250px;
            height: 414px;
            background: linear-gradient(
              180deg,
              rgba(39, 126, 255, 0.015) -3%,
              rgba(39, 177, 255, 0.12) 100%
            );
            box-shadow: inset 0px 10px 50px 0px rgba(55, 169, 238, 0.05);
            display: flex;
            justify-content: start;
            .item {
              width: 300px;
              height: 276px;
              display: flex;
              flex-direction: column;
              justify-content: start;
              align-items: center;

              .item_left {
                width: 100px;
                height: 120px;
                margin-bottom: 20px;
              }

              .item_right {
                width: 200px;
                height: 120px;
                display: flex;
                flex-direction: column;
                justify-content: space-evenly;
                align-items: center;
                .item_group_name {
                  font-size: 20px;
                  color: #ffffff;
                }
                .item_group_value {
                  font-size: 18px;
                  color: #cccccc;
                }
              }
            }
          }
        }

        .middle_text {
          width: 1250px;
          height: 180px;
          .chart_sb {
            margin-top: 6px;
            width: 1250px;
            height: 136px;
            background: linear-gradient(
              180deg,
              rgba(39, 126, 255, 0.015) -3%,
              rgba(39, 177, 255, 0.12) 100%
            );
            box-shadow: inset 0px 10px 50px 0px rgba(55, 169, 238, 0.05);
            display: flex;
            justify-content: space-around;
            .item {
              width: 600px;
              height: 136px;
              display: flex;
              justify-content: start;
              align-items: center;

              .item_left {
                width: 100px;
                height: 120px;
                margin-bottom: 20px;
              }

              .item_right {
                width: 400px;
                height: 120px;
                display: flex;
                flex-direction: column;
                justify-content: space-evenly;
                align-items: center;
                .item_group_name {
                  font-size: 20px;
                  color: #ffffff;
                }
                .item_group_value {
                  font-size: 18px;
                  color: #cccccc;
                }
              }
            }
          }
        }

        .title_guangyun {
          width: 124px;
          height: 70px;
          position: absolute;
          background: url(./guangyun.png) no-repeat;
          background-size: cover;
        }

        .title_sb {
          width: 1250px;
          height: 40px;
          background: linear-gradient(
            90deg,
            rgba(57, 125, 175, 0) -1%,
            rgba(57, 125, 175, 0.15) 48%,
            rgba(57, 125, 175, 0) 100%
          );
          font-family: Arial;
          font-size: 18px;
          font-weight: normal;
          line-height: 40px;
          letter-spacing: 0px;
          color: #ffffff;
          text-shadow: 0px 2px 24px #00c0ff;

          .title_bg {
            width: 548px;
            height: 40px;
            background: url(./titlebg.png) no-repeat;
            background-size: cover;

            span {
              padding-left: 40px;
            }
          }
        }

        .chart_sb {
          margin-top: 6px;
          width: 1250px;
          height: 134px;
          background: linear-gradient(
            180deg,
            rgba(39, 126, 255, 0.015) -3%,
            rgba(39, 177, 255, 0.12) 100%
          );
          box-shadow: inset 0px 10px 50px 0px rgba(55, 169, 238, 0.05);
          display: flex;
          justify-content: start;
        }
      }

      .middle_r {
        width: 614px;
        height: 660px;
        display: flex;
        flex-direction: column;
        justify-content: start;

        .middle_right {
          width: 614px;
          height: 320px;
          margin-bottom: 20px;

          .title_guangyun {
            width: 124px;
            height: 70px;
            position: absolute;
            background: url(./guangyun.png) no-repeat;
            background-size: cover;
          }

          .title_sb {
            width: 614px;
            height: 40px;
            background: linear-gradient(
              90deg,
              rgba(57, 125, 175, 0) -1%,
              rgba(57, 125, 175, 0.15) 48%,
              rgba(57, 125, 175, 0) 100%
            );
            font-family: Arial;
            font-size: 18px;
            font-weight: normal;
            line-height: 40px;
            letter-spacing: 0px;
            color: #ffffff;
            text-shadow: 0px 2px 24px #00c0ff;

            .title_bg {
              width: 548px;
              height: 40px;
              background: url(./titlebg.png) no-repeat;
              background-size: cover;

              span {
                padding-left: 40px;
              }
            }
          }

          .chart_sb {
            margin-top: 6px;
            width: 614px;
            height: 276px;
            background: linear-gradient(
              180deg,
              rgba(39, 126, 255, 0.015) -3%,
              rgba(39, 177, 255, 0.12) 100%
            );
            box-shadow: inset 0px 10px 50px 0px rgba(55, 169, 238, 0.05);
            display: flex;
            justify-content: start;
          }
        }
      }
    }
  }
}
</style>
